//
//  XLPlayerDecoder.h
//  FFMpegKitDemo
//
//  Created by ilongge on 2023/8/2.
//

#import <Foundation/Foundation.h>
#import <libavformat/avformat.h>

@class XLPlayerConfig;

@interface XLPlayerDecoder : NSObject

#pragma mark ------------------------- 初始化 / Initializer
/**
 * 类方法
 * Class Method
 * 初始化解码器，若初始化失败，可读取error字段值。
 * Initialize the decoder. If initialization failed, read error.
 * @param  formatContext 格式上下文 / AVFormatContext
 * @param  config 解码器配置 / Decoder Configuration
 * @param  videoStreamIndex 视频轨道索引 / video Stream Index
 * @param  audioStreamIndex 视频轨道索引 / audio Stream Index 
 * @param  error 错误 / Error
 * @return 解码器实例 / XLPlayerDecoder Instance
 */
+ (instancetype)decoderWithFormatContxt:(AVFormatContext *)formatContext
                                 config:(XLPlayerConfig *)config
                       videoStreamIndex:(int)videoStreamIndex
                       audioStreamIndex:(int)audioStreamIndex
                                  error:(NSError **)error;
/**
 * 实例方法
 * Instance Method
 * 初始化解码器，若初始化失败，可读取error字段值。
 * Initialize the decoder. If initialization failed, read error.
 * @param  formatContext 格式上下文 / AVFormatContext
 * @param  config 解码器配置 / Decoder Configuration
 * @param  videoStreamIndex 视频轨道索引 / video Stream Index
 * @param  audioStreamIndex 视频轨道索引 / audio Stream Index
 * @param  error 错误 / Error
 * @return 解码器实例 / XLPlayerDecoder Instance
 */
- (instancetype)initWithFormatContxt:(AVFormatContext *)formatContext
                              config:(XLPlayerConfig *)config
                    videoStreamIndex:(int)videoStreamIndex
                    audioStreamIndex:(int)audioStreamIndex
                               error:(NSError **)error;
/**
 * 解器器当前的配置
 * Current configuration of the decoder
 */
@property (readonly, strong, nonatomic) XLPlayerConfig *config;

- (void)decoderVideoPacket:(AVPacket)packet frame:(AVFrame *)frame yuvFrame:(AVFrame *)yuvFrame;

- (void)decoderAudioPacket:(AVPacket)packet frame:(AVFrame *)frame swrFrame:(AVFrame *)swrFrame;

@end


